%% MMG Capture and filtering
%
% Filter for MMG signals
% Edited : 01/02/2013
%

%%  Program written to extract the csv voltage traces from the MMG
%   Written by Edward Brial - 01/02/13
%   The eventual idea of this script will be to lead through the process of
%   opening 3 traces (no weight, mid weight and max weight, cutting out the middle section and finally RMSing it!

%% Importing the file

clear all;
clc; clf;
    
D1 = dlmread('capture1.csv',',',1,0);
D2 = dlmread('capture2.csv',',',1,0);
D3 = dlmread('capture3.csv',',',1,0);


Vraw1 = D1(:,2)*(3.3/1024);
Vrawcut = Vraw1(23800:end); 
Tbase1 = D1(:,1); %t increments are roughly 1192, whatever that is... and it starts at 38513204 (capture 1)
S1 = size(Vrawcut);
T1 = linspace(0, 1, S1(1));

Vraw2 = D2(:,2)*(3.3/1024);
Tbase2 = D2(:,1); %t increments are roughly 1192, whatever that is... and it starts at 38513204 (capture 1)

Vraw3 = D3(:,2)*(3.3/1024);
Tbase3 = D3(:,1); %t increments are roughly 1192, whatever that is... and it starts at 38513204 (capture 1)
S3 = size(Vraw3);
T3 = linspace(0, 1, S3(1));


%% plot the raw data

figure(1);
plot(Tbase1, Vraw1); 
title ('Raw voltage feed, no weight');

figure(2);
plot(Tbase2, Vraw2); 
title ('Raw voltage feed, 54kg');

figure(3);
plot(Tbase3, Vraw3); 
title ('Raw voltage feed, 126kg');

figure(4);
plot(T1, Vrawcut,'b', T3, Vraw3,'r');
title ('Overlay of heavy and light');

%% signal filtering



